import { login } from '@/api'
import { setToken } from '@/utils'
import { LOGIN_TOKEN } from '@/store/actionTypes'
import { message } from 'antd'

export function loginAction (mobile, code) {
  return async dispatch => {
    const res = await login(mobile, code)
    setToken(res.data.token)
    message.success('登录成功')
    dispatch({
      type: LOGIN_TOKEN,
      payload: res.data.token
    })
  }
}
